<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>ECharts Lines-Bus with Leaflet</title>
    <script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" include="echarts" src="../../dist/include-leaflet.js"></script>
<script type="text/javascript">
    var host = window.isLocal ? document.location.protocol + "//" + document.location.host : "http://support.supermap.com.cn:8090";
    var map, url = host + "/iserver/services/map-world/rest/maps/世界地图_Gray";
    map = L.map('map', {
        crs: L.CRS.EPSG4326,
        center: [39.8, 116.5],
        maxZoom: 18,
        zoom: 9
    });
    L.supermap.tiledMapLayer(url).addTo(map);

    $.get('../data/lines-bus.json', function (data) {
        var busLines = [].concat.apply([], data.map(function (busLine, idx) {
            var prevPt;
            var points = [];
            for (var i = 0; i < busLine.length; i += 2) {
                var pt = [busLine[i], busLine[i + 1]];
                if (i > 0) {
                    pt = [
                        prevPt[0] + pt[0],
                        prevPt[1] + pt[1]
                    ];
                }
                prevPt = pt;

                points.push([pt[0] / 1e4, pt[1] / 1e4]);
            }
            return {
                coords: points
            };
        }));
        option = {
            series: [{
                type: 'lines',
                coordinateSystem: 'leaflet',
                polyline: true,
                data: busLines,
                silent: true,
                lineStyle: {
                    normal: {
                        color: 'rgb(200, 35, 45)',
                        opacity: 0.2,
                        width: 1
                    }
                },
                progressiveThreshold: 500,
                progressive: 200
            }]
        };
        L.supermap.echartsLayer(option).addTo(map);
    });


</script>
</body>
</html>